#include <stdio.h>

void strcpyMem(char** szDestino, const char* szCadena) {
  int iLen = 0;
  int iCadenaNula = 0;
  iCadenaNula = strcmp(szCadena, "");
  iLen = strlen(szCadena);
  free(&szDestino);
  if (iCadenaNula != 0) {
    *szDestino = (char*)malloc((size_t)(iLen * sizeof(char)));
    strcpy(*szDestino, szCadena);
  } else {
    *szDestino = NULL;
  };
};

void strcat2Mem(char** acCadena, char c) {
  int iLen = 0;
  char acChar[2];
  acChar[0] = c;
  acChar[1] = '\0';
  if (*acCadena == NULL) {
    iLen = 0;
    *acCadena = (char*)malloc((size_t)sizeof(char));
    strcpy(*acCadena, acChar);
  } else {
    iLen = strlen(*acCadena);
    *acCadena = (char*)realloc(*acCadena, ((size_t)sizeof(char) * iLen) + 2);
    strcat(*acCadena, acChar);
  };
};
